package com.zzptc.fxh.mychat.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.zzptc.fxh.mychat.Bean.User;
import com.zzptc.fxh.mychat.R;

import java.util.List;

public class ContactAdapter extends ArrayAdapter<User> {
    int resourceid;

    public ContactAdapter(@NonNull Context context, int resource, @NonNull List<User> objects) {
        super(context, resource, objects);
        this.resourceid=resource;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        View view=convertView;
        if (view==null){
            view= LayoutInflater.from(getContext()).inflate(resourceid,null);
        }
        ImageView contactimg=view.findViewById(R.id.contactimg);
        TextView contactname=view.findViewById(R.id.contactname);
        User user=getItem(position);
        contactimg.setImageResource(user.getUserimg());
        contactname.setText(user.getName());
        return view;
    }
}
